import { createSlice } from '@reduxjs/toolkit';
import type { PayloadAction } from '@reduxjs/toolkit';

import { ICinema } from '@/types/Cinema';

// 定义 slice state 的类型
interface CinemaState {
  list: ICinema[];
}

// 使用该类型定义初始 state
const initialState: CinemaState = {
  list: [],
};

const slice = createSlice({
  name: 'cinema',
  initialState,
  reducers: {
    changeCinemaList(state, action: PayloadAction<ICinema[]>) {
      state.list = action.payload || [];
    },
    fetchCinemaList(state, action) {},
  },
});

export const { changeCinemaList, fetchCinemaList } = slice.actions;
export default slice.reducer;
